package ${package}.${moduleName}.service.impl;
import ${package}.${moduleName}.model.${className};
import ${package}.${moduleName}.service.${className}Service;
import org.springframework.stereotype.Service;
import java.util.List;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qdone.framework.core.page.CoreUtil;
import com.qdone.framework.core.page.PageInfo;
import com.qdone.framework.core.page.PageList;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.beans.factory.annotation.Autowired;

/**
* ${classname}服务接口
* ${comments}
* @author ${author}
* @email ${email}
* @date ${datetime}
*/
@Service("${classname}Service")
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
public class ${className}Service{

	@Autowired
	private ${className}Dao ${classname}Dao;

    /**
     * 分页查询
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public PageList<${className}> selectPage(${className} entity) {
	    PageList<${className}> pageList = new PageList<${className}>();
		PageInfo pageInfo = CoreUtil.createBootStrapPage(entity, true);
		String orders = CoreUtil.createSort(pageInfo, true);
		PageHelper.offsetPage(pageInfo.getCurrentNumber(), pageInfo.getPageSize());
		PageHelper.orderBy(orders);// 插件排序
		List<${className}> list = ${classname}Dao.select(entity);
		// 设置总记录数
		pageList.setList(list);
		Page<${className}> pg = (Page<${className}>) list;
		pageInfo.setRecordCount(pg.getTotal());
		pageList.setPageInfo(pageInfo);
		return pageList;
	}


	/**
	* 查看
	* @param pk 主键
	* @return 根据主键查询结果
	*/
	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public ${className} view(${pk.attrType} pk) {
	    return ${classname}Dao.view(entity);;
	}


	/**
	* 新增(主键可以使用数据库自增，也可以使用mybatis生成)
	* @param entity 新增参数
	* @return 新增结果,结果中含有主键，操作结果
	*/
	@Override
	@Transactional(readOnly = false,rollbackFor = Exception.class)
	public ${className} insert(${className} entity) {
	    entity.setOperateResult(${classname}Dao.insert(entity));
	    return entity;
	}

	/**
	* 更新
	* @param entity 更新参数
	* @return 更新结果,结果中含有操作结果
	*/
	@Override
	@Transactional(readOnly = false,rollbackFor = Exception.class)
	public ${className} update(${className} entity){
	    entity.setOperateResult(${classname}Dao.update(entity));
	    return entity;
	}

	/**
	* 批量删除
	* @param pkList 对象集合
	* @return 批量删除集合参数
	*/
	@Override
	@Transactional(readOnly = false,rollbackFor = Exception.class)
	public int batchDelete(List<${className}> pkList) {
	    return ${classname}Dao.batchDelete(pkList);
    }


}
